using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
using Microsoft.Synchronization;

namespace ToodleOutlook
{
    class ToodleDoProvider : KnowledgeSyncProvider, IChangeDataRetriever, INotifyingChangeApplierTarget
    {
        public String generateKey()
        {
            String userID = "td475d918273742";
            String tokenUrl = "http://www.toodledo.com/api.php?method=getToken;userid=" + userID;
            try{
                    XmlReader theReader = new XmlTextReader(tokenUrl);
                    theReader.MoveToContent();
                    String theToken = theReader.ReadContentAsString();
                    String theKey = Util.MD5("fraggle") + theToken + userID ;
                    return theKey;
                
            }
            catch(WebException ex)
            {
                return "Error getting token for key";
            }
        }



        public override void BeginSession(SyncProviderPosition position, SyncSessionContext syncSessionContext)
        {
            throw new NotImplementedException();
        }

        public override void GetSyncBatchParameters(out uint batchSize, out SyncKnowledge knowledge)
        {
            throw new NotImplementedException();
        }

        public override ChangeBatch GetChangeBatch(uint batchSize, SyncKnowledge destinationKnowledge,
                                                   out object changeDataRetriever)
        {
            throw new NotImplementedException();
        }

        public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges,
                                                object changeDataRetriever, SyncCallbacks syncCallbacks,
                                                SyncSessionStatistics sessionStatistics)
        {
            throw new NotImplementedException();
        }

        public override FullEnumerationChangeBatch GetFullEnumerationChangeBatch(uint batchSize,
                                                                                 SyncId lowerEnumerationBound,
                                                                                 SyncKnowledge knowledgeForDataRetrieval,
                                                                                 out object changeDataRetriever)
        {
            throw new NotImplementedException();
        }

        public override void ProcessFullEnumerationChangeBatch(ConflictResolutionPolicy resolutionPolicy,
                                                               FullEnumerationChangeBatch sourceChanges,
                                                               object changeDataRetriever, SyncCallbacks syncCallbacks,
                                                               SyncSessionStatistics sessionStatistics)
        {
            throw new NotImplementedException();
        }

        public override void EndSession(SyncSessionContext syncSessionContext)
        {
            throw new NotImplementedException();
        }

        public ulong GetNextTickCount()
        {
            throw new NotImplementedException();
        }

        public IChangeDataRetriever GetDataRetriever()
        {
            throw new NotImplementedException();
        }

        public bool TryGetDestinationVersion(ItemChange sourceChange, out ItemChange destinationVersion)
        {
            throw new NotImplementedException();
        }

        public void SaveItemChange(SaveChangeAction saveChangeAction, ItemChange change, SaveChangeContext context)
        {
            throw new NotImplementedException();
        }

        public void SaveChangeWithChangeUnits(ItemChange change, SaveChangeWithChangeUnitsContext context)
        {
            throw new NotImplementedException();
        }

        public void SaveConflict(ItemChange conflictingChange, object conflictingChangeData,
                                 SyncKnowledge conflictingChangeKnowledge)
        {
            throw new NotImplementedException();
        }

        public void StoreKnowledgeForScope(SyncKnowledge knowledge, ForgottenKnowledge forgottenKnowledge)
        {
            throw new NotImplementedException();
        }

        public object LoadChangeData(LoadChangeContext loadChangeContext)
        {
            throw new NotImplementedException();
        }

        public override SyncIdFormatGroup IdFormats
        {
            get { throw new NotImplementedException(); }
        }
    }
}
